#ifndef _MEMORY_TOOLKIT_H
#define _MEMORY_TOOLKIT_H

#include "../stdafx.h"

namespace toolkit
{
	template <typename T> static inline T * allocateMemory(unsigned int nb_objects)
	{
		T * mem = (T *)::VirtualAlloc(NULL, nb_objects * sizeof(T), MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
		if (!mem)
		{
			DWORD dw = ::GetLastError(); 
			assert(mem);
		}
		return mem;
	}

	template <typename T> static inline void releaseMemory(T * ojbects)
	{
		::VirtualFree((LPVOID) ojbects, 0, MEM_RELEASE);
	}
}
#endif //_MEMORY_TOOLKIT_H